package com.diaoyanbao.util;

/**
 * 文件过滤类
 * 
 * @author dingxs
 */
public class FileFilter {
    private String filename;
    private String[] filetypes;

    public String getFilename() {
        return filename;
    }

    public void setFilename(String filename) {
        this.filename = filename;
    }

    public String[] getFiletype() {
        return filetypes;
    }

    public void setFiletype(String[] filetypes) {
        this.filetypes = filetypes;
    }

    /**
     * 判断文件是否是指定类型
     * 
     * @return
     */
    public boolean isInTypes(String filename) {
        boolean flag = false;
        String suffix = filename.substring(filename.lastIndexOf(".") + 1);
        for (String filetype : filetypes) {
            if (filetype.trim().toLowerCase().equals(suffix)) {
                flag = true;
                break;
            }
        }
        return flag;
    }
}
